<?php

namespace Mcm\RepasBundle\Entity;

use Mcm\RepasBundle\Entity\Commentaire as Commentaire;
use Mcm\RepasBundle\Entity\Paiement as Paiement;
use Doctrine\ORM\Mapping as ORM;

/**
 * Repas
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Mcm\RepasBundle\Entity\RepasRepository")
 */
class Repas {

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="titre", type="string", length=150)
     */
    private $titre;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="date_repas", type="datetime")
     */
    private $date_repas;

    /**
     * @var integer
     *
     * @ORM\Column(name="nombre_place", type="integer")
     */
    private $nombre_place;

    /**
     * @var float
     *
     * @ORM\Column(name="prix", type="float")
     */
    private $prix;

    /**
     * @var string
     *
     * @ORM\Column(name="menu", type="text")
     */
    private $menu;

    /**
     * @var string
     *
     * @ORM\Column(name="adresse", type="string", length=255)
     */
    private $adresse;

    /**
     * @var string
     *
     * @ORM\Column(name="entree", type="string", length=150)
     */
    private $entree;

    /**
     * @var string
     *
     * @ORM\Column(name="plat", type="string", length=150)
     */
    private $plat;

    /**
     * @var string
     *
     * @ORM\Column(name="dessert", type="string", length=150)
     */
    private $dessert;

    /**
     *  /**
     * @var array
     *
     * @ORM\Column(name="notes", type="array", nullable=true)
     */
    private $notes;

    /**
     * @ORM\OneToMany(targetEntity="Mcm\RepasBundle\Entity\Commentaire", mappedBy="repas")
     * 
     */
    private $commentaires;

    /**
     * @ORM\ManyToOne(targetEntity="Mcm\UserBundle\Entity\User", inversedBy="repashotes")
     * @ORM\JoinColumn(nullable=false)
     */
    private $hote;
    
    /**
     * @ORM\OneToMany(targetEntity="Mcm\RepasBundle\Entity\Paiement", mappedBy="repas")
     * 
     */
    private $paiements;

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId() {
        return $this->id;
    }

    /**
     * Set titre
     *
     * @param string $titre
     * @return Repas
     */
    public function setTitre($titre) {
        $this->titre = $titre;

        return $this;
    }

    /**
     * Get titre
     *
     * @return string 
     */
    public function getTitre() {
        return $this->titre;
    }

    /**
     * Set date_repas
     *
     * @param \DateTime $dateRepas
     * @return Repas
     */
    public function setDateRepas($dateRepas) {
        $this->date_repas = $dateRepas;

        return $this;
    }

    /**
     * Get date_repas
     *
     * @return \DateTime 
     */
    public function getDateRepas() {
        return $this->date_repas;
    }

    /**
     * Set nombre_place
     *
     * @param integer $nombrePlace
     * @return Repas
     */
    public function setNombrePlace($nombrePlace) {
        $this->nombre_place = $nombrePlace;

        return $this;
    }

    /**
     * Get nombre_place
     *
     * @return integer 
     */
    public function getNombrePlace() {
        return $this->nombre_place;
    }

    /**
     * Set prix
     *
     * @param float $prix
     * @return Repas
     */
    public function setPrix($prix) {
        $this->prix = $prix;

        return $this;
    }

    /**
     * Get prix
     *
     * @return float 
     */
    public function getPrix() {
        return $this->prix;
    }

    /**
     * Set menu
     *
     * @param string $menu
     * @return Repas
     */
    public function setMenu($menu) {
        $this->menu = $menu;

        return $this;
    }

    /**
     * Get menu
     *
     * @return string 
     */
    public function getMenu() {
        return $this->menu;
    }

    /**
     * Set adresse
     *
     * @param string $adresse
     * @return Repas
     */
    public function setAdresse($adresse) {
        $this->adresse = $adresse;

        return $this;
    }

    /**
     * Get adresse
     *
     * @return string 
     */
    public function getAdresse() {
        return $this->adresse;
    }

    /**
     * Set entree
     *
     * @param string $entree
     * @return Repas
     */
    public function setEntree($entree) {
        $this->entree = $entree;

        return $this;
    }

    /**
     * Get entree
     *
     * @return string 
     */
    public function getEntree() {
        return $this->entree;
    }

    /**
     * Set plat
     *
     * @param string $plat
     * @return Repas
     */
    public function setPlat($plat) {
        $this->plat = $plat;

        return $this;
    }

    /**
     * Get plat
     *
     * @return string 
     */
    public function getPlat() {
        return $this->plat;
    }

    /**
     * Set dessert
     *
     * @param string $dessert
     * @return Repas
     */
    public function setDessert($dessert) {
        $this->dessert = $dessert;

        return $this;
    }

    /**
     * Get dessert
     *
     * @return string 
     */
    public function getDessert() {
        return $this->dessert;
    }

    public function getHote() {
        return $this->hote;
    }

    public function setHote($hote) {
        $this->hote = $hote;
    }

    public function getNote() {
        if (sizeof($this->notes) == 0) {
            return 0;
        } else {
            $total = 0;
            for ($i = 0; $i < sizeof($this->notes); $i++) {
                $total = $total + $this->notes[$i];
            }
            return round($total / sizeof($this->notes),2);
        }
    }

    public function addNote($note) {
        $this->notes[] = $note;
    }

    public function getCommentaires() {
        return $this->commentaires;
    }

    public function addCommentaire(Commentaire $commentaire) {
        $this->commentaires[] = $commentaire;
        return $this;
    }

    public function removeCommentaire(Commentaire $commentaire) {
        $this->commentaires->removeElement($commentaire);
        return $this;
    }
     public function getPaiements() {
        return $this->paiements;
    }

    public function addPaiement(Paiement $paiement) {
        $this->paiements[] = $paiement;
        return $this;
    }

    public function removePaiement(Paiement $paiement) {
        $this->paiements->removeElement($paiement);
        return $this;
    }

}